package com.example.controller;


import com.example.entity.TbSpecification;
import com.example.entity.TbSpecificationOption;
import com.example.service.SpecificationService;
import com.example.util.PageResult;
import com.example.util.Result;
import com.example.vo.SpecificationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/specification")
@CrossOrigin
public class SpecificationController {

    @Autowired
    private SpecificationService service;
    @PostMapping("/loadList")
    public PageResult<TbSpecification> loadList(Integer page,Integer pageSize,@RequestBody(required = false) SpecificationVo specificationVo){
        return service.loadList(page,pageSize,specificationVo);
    }


    @PostMapping("/add")
    public Result add(String specName,@RequestBody TbSpecificationOption  specificationOption ){
       int count = service.add(specName,specificationOption);
       if(count >0) return  Result.success("添加成功！");
       return Result.error("添加失败！");
    }
}
